package com.youdianda.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.youdianda.entity.SysUser;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * 用户表 Mapper 接口
 * </p>
 *
 * @author mosen
 * @since 2023-05-15
 */
@Mapper
public interface SysUserMapper extends BaseMapper<SysUser> {

    @Select("select * from sys_user")
    List<SysUser> selectAllUser();

    @Update("update sys_user set role_id=#{roleId} where id=#{id}")
    void updateRoleId(SysUser sysUser);


    @Insert("insert into sys_user (login_name, password, name, email, phone, role_id, status) VALUES (#{login_name},#{password},#{name},#{email},#{phone},#{roleId},#{status})")
    void insertUser(SysUser sysUser);

    @Select("select role_id from sys_user where id=#{id}")
    String getRoleIdById(String id);

    void updateUserById(SysUser sysUser);

    @Select("select count(*) from sys_user")
    Integer getUserCount();
}
